import Application from 'similar-server/dist/application';
import router from './router';
import bodyParser from 'body-parser';
import OAuthServer from './helpers/OAuthServer';

const app = Application();
app.oauth = new OAuthServer({
  model: {}, 
  // See https://github.com/oauthjs/node-oauth2-server for specification
});

app.plugin(bodyParser.json())
app.plugin(bodyParser.urlencoded({ extended: false }))

app.route('/oauth/authorize', app.oauth.authorize());
app.route('/oauth/token', app.oauth.token());
app.route('/oauth/authenticate', app.oauth.authenticate());

// router
app.router(router);
// static plugin
app.static('assets');
// init routes & plugins
app.init();
// listen 3002 port
app.listen(3002);

